﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace GameName1
{
    class RocketLauncher : IWeapon
    {
        List<IWeaponObserver> Observers = new List<IWeaponObserver>();
        public WeaponState State { get; set; }

        public RocketLauncher()
        {
            State = new WeaponReady(this);
        }

        public void Fire(Vector2 position)
        {
            Projectile p = new Rocket(new Vector2(position.X+20,position.Y-10), new Vector2(0, -7));
            State.Fire(this,p);   
        }

        public void setState(WeaponState state)
        {
            State = state;
        }

        public void Notify(Projectile projectile)
        {
            XnaProjectileDecorator p = new XnaProjectileDecorator(projectile, Rocket.sprite);
            foreach (IWeaponObserver observer in Observers)
            {
                observer.Update(p);
            }
        }

        public void RegisterObserver(IWeaponObserver observer)
        {
            Observers.Add(observer);
        }

        public void RemoveObserver(IWeaponObserver observer)
        {
            Observers.Remove(observer);
        }

        
    }
}
